<%@ page   pageEncoding="UTF-8"%>

<style type="text/css">
.pageLine {
    height: 20px;
    line-height: 20px;
}

.pageInfo{
	float: left;
	padding: 6px 12px;
}
.floatLeft{
	float: left;
}
</style>
<script src="<%=request.getContextPath()%>/views/sysdefault/js/jquery.min.js?v=2.1.4"></script>
<script type=text/javascript>

	var totalpage = ${pageInfo.totalPageCount};
	var totalCount = ${pageInfo.totalCount};
	var currentPage = ${pageInfo.currentPage};
	var pageSize = ${pageInfo.pageSize};
    
    var gotoPage = function(page){
    	
    	if(page < 1 || page > totalpage){
    		return;
    	}
    	
    	$('#currentPage').val(page);
        $('#pagerForm').submit();
    };
    
    var changePageSize = function(val){
    	$('#pageSize').val(val);
    	$('#pagerForm').submit();
    }
    
    $(function(){
    	
    	$('#pagerForm').append('<input type="hidden" name="pageSize" id="pageSize" value="'+pageSize+'" />');
    	
    	var outstr = "";
    	
    	outstr = outstr + '<div class="btn-group">';
    	outstr = outstr + '<button class="btn btn-white" onclick="gotoPage(1);">首页</button>';
    	outstr = outstr + '<button class="btn btn-white" onclick="gotoPage('+(currentPage-1)+');"><i class="fa fa-chevron-left pageLine"></i></button>';
    	
    	if (totalpage > 1) {
    		var startNum;
    		var endNum;
    		if (currentPage - 3 <= 1) {
    			startNum = 1;
			}else{
				startNum = currentPage - 3;
			}
    		if (currentPage + 3 >= totalpage) {
    			endNum = totalpage;
			}else{
				endNum = currentPage + 3;
			}
    		
			if (startNum > 1) {
				outstr = outstr + '<button class="btn btn-white" disabled="disabled">...</button>';
			}
			
			for (var i = startNum; i <= endNum; i++) {
				if (i == currentPage) {
					outstr = outstr + '<button class="btn btn-white active">'+i+'</button>';
				}else{
					outstr = outstr + '<button class="btn btn-white" onclick="gotoPage('+i+');" >'+i+'</button>';
				}
			}
			if (endNum < totalpage) {
				outstr = outstr + '<button class="btn btn-white" disabled="disabled">...</button>';
			}
		}else{
			outstr = outstr + '<button class="btn btn-white active">1</button>';
		}
    	
    	
    	outstr = outstr + '<button class="btn btn-white" onclick="gotoPage('+(currentPage+1)+');"><i class="fa fa-chevron-right pageLine"></i></button>';
    	outstr = outstr + '<button class="btn btn-white" onclick="gotoPage('+totalpage+');">&nbsp;末页</button>';
    	
    	outstr = outstr + '<div class="pageLine pageInfo">';
    	outstr = outstr + '每页10条&nbsp;&nbsp;&nbsp;';
    	outstr = outstr + '共' + totalCount + '条    ';
    	outstr = outstr + '</div>';
    	
    	/* outstr = outstr + '<div class="floatLeft">';
    	outstr = outstr + '<select id="pageSelect" class="form-control" onChange="changePageSize(this.value)" >'
    	outstr = outstr + '<option value="20">20</option>'
    	outstr = outstr + '<option value="100">50</option>'
    	outstr = outstr + '<option value="200">100</option>'
    	outstr = outstr + '<option value="500">200</option>'
    	outstr = outstr + '</select>'
    	outstr = outstr + '</div>';
    	
    	outstr = outstr + '<div class="pageLine pageInfo">';
    	outstr = outstr + '条';
    	outstr = outstr + '</div>'; */
    	
    	outstr = outstr + '</div>';
    	
    	$("#pageList").html(outstr);
    	
    	$("#pageSelect").val(pageSize);
    });
</script>
<div id="pageList" >
	
</div>